package com.newhonor.server.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author newhonor
 * @Date 2021/2/20 11:38
 * @Version 1.0
 **/
@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello() {
        return "hello";
    }

    @GetMapping("/employee/basic/hello")
    public String hello2() {
        return "/employee/basic/hello";
    }


    @GetMapping("/employee/advanced/hello")
    public String hello3() {
        return "/employee/advanced/hello";
    }

    public static int id = 0;
    public MyThread myThread = null;

    @GetMapping("/start")
    public void start() {
        myThread = new MyThread();
        myThread.start();
    }

    @GetMapping("/end")
    public void end() {
        myThread.interrupt();
    }

    class MyThread extends Thread {
        @Override
        public void run() {
            while(true){
                if(Thread.currentThread().isInterrupted()){
                    break;
                }
                System.out.println(id++);
            }
        }
    }
}

